home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group98b.txt / 000173_icon-group-sender _Mon Aug 31 09:30:37 1998.msg < prev    next >
Internet Message Format  |  2000-09-20  |  3KB

  1. Return-Path: <icon-group-sender>
  2. Received: from kingfisher.CS.Arizona.EDU (kingfisher.CS.Arizona.EDU [192.12.69.239])
  3.     by baskerville.CS.Arizona.EDU (8.9.1a/8.9.1) with SMTP id JAA01124
  4.     for <icon-group-addresses@baskerville.CS.Arizona.EDU>; Mon, 31 Aug 1998 09:30:36 -0700 (MST)
  5. Received: by kingfisher.CS.Arizona.EDU (5.65v4.0/1.1.8.2/08Nov94-0446PM)
  6.     id AA20694; Mon, 31 Aug 1998 09:30:10 -0700
  7. Date: Mon, 31 Aug 1998 09:11:59 -0700
  8. From: kwalker@sfo.harbinger.com (Ken Walker)
  9. Message-Id: <199808311611.JAA20585@varda.premenos.com>
  10. To: icon-group@optima.CS.Arizona.EDU
  11. Subject: Re: A hood fan is guard to mind.
  12. Mime-Version: 1.0
  13. Content-Type: text/plain; charset=us-ascii
  14. Content-Transfer-Encoding: 7bit
  15. Content-Md5: 0iWoS3eDDqPo4J69Q7wyKA==
  16. Content-Transfer-Encoding: 7bit
  17. Content-Transfer-Encoding: 7bit
  18. Errors-To: icon-group-errors@optima.CS.Arizona.EDU
  19. Content-Transfer-Encoding: 7bit
  20. Status: RO
  21. Content-Length: 1524
  22.  
  23. I apologize. The version of the program I sent out did not have
  24. a procedure that generated results, so it was not a recursive generator.
  25. Here is a version that is.
  26.  
  27. procedure main()
  28.    local fillers, firstChar, remainingChars
  29.  
  30.    #
  31.    # The sentence is broken into three categories:
  32.    #   parts not participating in the substitution
  33.    #   the initial characters of the words involved in substitution
  34.    #   the tail of the words involved in substitution
  35.    #
  36.    fillers :=    ["A ",    " ",  " is ", " to ",    "."]
  37.    firstChar :=     ["g",    "m",   "h",     "f"]
  38.    remainingChars := ["ood",  "an",  "ard",    "ind"]
  39.  
  40.    every write(polyspoonerism(fillers, firstChar, remainingChars, ""))
  41. end
  42.  
  43. procedure polyspoonerism(
  44.   fillers,        # words before each participating word
  45.   firstChar,      # first characters to use in substitutions
  46.   remainingChars, # words (w/out 1st char) that are participating
  47.   sentence)       # sentence so far
  48.  
  49.   local indx
  50.  
  51.   if *remainingChars = 0 then
  52.      return sentence || (fillers[1] | "")
  53.  
  54.   #
  55.   # Use each of the remaining first characters
  56.   #
  57.   every indx := 1 to *firstChar  do {
  58.      #
  59.      # Add the next set of parts to the sentence then call
  60.      # the function recursively.
  61.      #
  62.      suspend polyspoonerism(fillers[2:0],
  63.         firstChar[1:indx] ||| firstChar[indx+1:0],
  64.         remainingChars[2:0],
  65.         sentence || fillers[1] || firstChar[indx] || remainingChars[1])
  66.   }
  67. end
  68.  
  69.  
  70. Ken Walker, kenneth.walker@sfo.harbinger.com
  71. Harbinger Coporation, Concord, Ca. 94520
  72.  
  73.